import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class Test {

    public static void main(String[] args) {
        ExecutorService service = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 5000; i++) {
            int count = i;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("第"+count+"个任务"+" name: "+Thread.currentThread().getName());
                }
            });
        }
    }
    public static void main1(String[] args) {

        //1.创建最普通的线程池、可以根据任务的数目。自动进行线程扩容
        Executors.newCachedThreadPool();
        //2.创建固定数目的线程池
        Executors.newFixedThreadPool(10);
        //3.创建一个只含单个线程的线程池
        Executors.newSingleThreadExecutor();
        //4.创建一个固定线程个数，但是任务延时执行的线程池
        Executors.newScheduledThreadPool(10);

    }
}
